package com.fs.base.utils;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class CollectionTools {
	/**
	 * 
	 * @param list
	 * @param feildName
	 * @return
	 */
	public static Set<Object> convertListFeild2Set(List<?> list,String feildName){
		Set<Object> set = new HashSet<Object>();
		if(list!=null && list.size()>0){
			JSONObject json = null;
			for(Object m : list ){
				json = (JSONObject) JSON.toJSON(m);
				if(json.containsKey(feildName)){
					Object value = json.get(feildName);
					if(value==null) continue;
					set.add(value);
				}
			}
		}
		return set;
	}
}
